package 华为练习;

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Created by hest0 on 2017/7/12.
 */
public class K个最小的数字 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int k = sc.nextInt();

            PriorityQueue<Integer> pq = new PriorityQueue<>(k, new Comparator<Integer>() {
                @Override
                public int compare(Integer o1, Integer o2) {
                    return o1 < o2 ? -1 : 1;
                }
            });

            for (int i = 0; i < n; i++) {
                pq.add(sc.nextInt());
            }

            for (int i = 0; i < k - 1; i++) {
                System.out.print(pq.poll());
                System.out.print(" ");
            }
            System.out.println(pq.poll());

        }
        sc.close();
    }

}
